mirror of
https://github.com/felixfoertsch/wordpress-dev-env.git
synced 2026-04-18 15:28:44 +02:00
Initial commit
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript\AceEditor;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Theme extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'theme-xcode.js';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript\AceEditor;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ACEditor extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'ace.js';
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript\AceEditor;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ACEExtLanguageTools extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'ext-language_tools.js';
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript\AceEditor;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ACEExtSearchBox extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'ext-searchbox.js';
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript\AceEditor;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ACEModePHP extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'mode-php.js';
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
define("ace/theme/xcode",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-xcode",t.cssText=".ace-xcode .ace_gutter {background: #e8e8e8;color: #333}.ace-xcode .ace_print-margin {width: 1px;background: #e8e8e8}.ace-xcode {background-color: #FFFFFF;color: #000000}.ace-xcode .ace_cursor {color: #000000}.ace-xcode .ace_marker-layer .ace_selection {background: #B5D5FF}.ace-xcode.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #FFFFFF;}.ace-xcode .ace_marker-layer .ace_step {background: rgb(198, 219, 174)}.ace-xcode .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #BFBFBF}.ace-xcode .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.071)}.ace-xcode .ace_gutter-active-line {background-color: rgba(0, 0, 0, 0.071)}.ace-xcode .ace_marker-layer .ace_selected-word {border: 1px solid #B5D5FF}.ace-xcode .ace_constant.ace_language,.ace-xcode .ace_keyword,.ace-xcode .ace_meta,.ace-xcode .ace_variable.ace_language {color: #C800A4}.ace-xcode .ace_invisible {color: #BFBFBF}.ace-xcode .ace_constant.ace_character,.ace-xcode .ace_constant.ace_other {color: #275A5E}.ace-xcode .ace_constant.ace_numeric {color: #3A00DC}.ace-xcode .ace_entity.ace_other.ace_attribute-name,.ace-xcode .ace_support.ace_constant,.ace-xcode .ace_support.ace_function {color: #450084}.ace-xcode .ace_fold {background-color: #C800A4;border-color: #000000}.ace-xcode .ace_entity.ace_name.ace_tag,.ace-xcode .ace_support.ace_class,.ace-xcode .ace_support.ace_type {color: #790EAD}.ace-xcode .ace_storage {color: #C900A4}.ace-xcode .ace_string {color: #DF0002}.ace-xcode .ace_comment {color: #008E00}.ace-xcode .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)})
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ChechboxList extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'checkbox-list.js';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ErrorsDialog extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'ErrorsDialog.js';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
( function( $ )
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
WCFEErrorsDialog = new function()
|
||||
{
|
||||
|
||||
this.show = function( errorsList )
|
||||
{
|
||||
|
||||
// Create errors list
|
||||
var errorsListEle = $( '#wcfe-errors-dialog-errors-list' ).empty();
|
||||
|
||||
for ( var errIndex = 0; errIndex < errorsList.length; errIndex ++ )
|
||||
{
|
||||
errorsListEle.append( '<li>' + errorsList[ errIndex ] + '</li>' );
|
||||
}
|
||||
|
||||
// Show Popup
|
||||
tb_show( WCFEErrorsDialogL10N.title , '#TB_inline?inlineId=wcfe-errors-dialog&width=500px&height=400px' )
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} ) ( jQuery );
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
return array
|
||||
(
|
||||
'title' => $this->__( 'Config File Editor Errors' ),
|
||||
);
|
||||
@@ -0,0 +1,437 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
( function( $ )
|
||||
{
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
*/
|
||||
var editInput, childListToggler, addNewChildEle;
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
*/
|
||||
var _onediting = function( event )
|
||||
{
|
||||
|
||||
if ( event.keyCode == 13 )
|
||||
{
|
||||
|
||||
// End Edit
|
||||
endEdit( 'save' );
|
||||
|
||||
// Dont submit
|
||||
return false;
|
||||
}
|
||||
else if ( event.keyCode == 27 )
|
||||
{
|
||||
endEdit();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
var _oninlineadd = function( event )
|
||||
{
|
||||
var link = $( this );
|
||||
|
||||
// Get parent checkbox name
|
||||
var li = link.parent().parent();
|
||||
var parentName = li.find( '>input[type="checkbox"]' ).prop( 'name' );
|
||||
|
||||
// Create new checkbox item from parent checkbox
|
||||
var newLi = li.clone()
|
||||
newLi.find( '>ul' ).remove();
|
||||
newLi.find( '>span' ).text( '' );
|
||||
|
||||
newLi.find( 'input[type="checkbox"]' ).prop( 'name', parentName );
|
||||
|
||||
li.find( '>ul' ).prepend( newLi );
|
||||
|
||||
_onedit( { target : newLi.find( '>span' ).get( 0 ) } );
|
||||
|
||||
link.hide();
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
*/
|
||||
var _oninputaddnew = function( event )
|
||||
{
|
||||
switch ( event.keyCode )
|
||||
{
|
||||
case 13:
|
||||
|
||||
var input = $( event.target );
|
||||
|
||||
// Add to checkbox list when pressing enter
|
||||
var list = input.prev();
|
||||
var listItem = $( '<li></li>' ).appendTo( list );
|
||||
var itemName = input.prop( 'id' ) + '[]';
|
||||
var textEle;
|
||||
var options = list.data( 'WCFECheckboxList' ).options;
|
||||
|
||||
$( '<input type="checkbox" name="' + itemName + '" value="' + input.val() + '" checked="checked" />' )
|
||||
|
||||
.appendTo( listItem )
|
||||
|
||||
.after( textEle = $( '<span>' + input.val() + '</span>' ) );
|
||||
|
||||
if ( options.allowEdit )
|
||||
{
|
||||
textEle.click( _onedit );
|
||||
}
|
||||
|
||||
// Clear input
|
||||
input.val( '' );
|
||||
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
var _onedit = function( event )
|
||||
{
|
||||
var li = $( event.target.parentNode );
|
||||
var textEle = $( event.target );
|
||||
|
||||
// Expand list
|
||||
li.parent().addClass( 'expanded' ).show();
|
||||
|
||||
textEle.hide();
|
||||
|
||||
// Show input with checkbox value
|
||||
editInput.insertBefore( textEle )
|
||||
.css( { width : '40%' } )
|
||||
.val( textEle.text() )
|
||||
.show()
|
||||
.focus();
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
*/
|
||||
var _onunchecked = function( event )
|
||||
{
|
||||
deleteItem( event.target );
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param checkbox
|
||||
*/
|
||||
var deleteItem = function( checkbox )
|
||||
{
|
||||
editInput.detach();
|
||||
childListToggler.detach();
|
||||
|
||||
if ( addNewChildEle )
|
||||
{
|
||||
addNewChildEle.detach();
|
||||
}
|
||||
|
||||
$( checkbox ).parent().remove();
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
*/
|
||||
var endEdit = function( action )
|
||||
{
|
||||
|
||||
var li = editInput.parent();
|
||||
var checkbox = li.find( 'input[type="checkbox"]' );
|
||||
var textEle = li.find( '>span' );
|
||||
value = editInput.val();
|
||||
|
||||
if ( editInput.css( 'display' ) == 'none' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// hide edit input element
|
||||
editInput.hide();
|
||||
|
||||
textEle.show();
|
||||
|
||||
// Remove if new and no value specified
|
||||
if ( ! value || action == undefined )
|
||||
{
|
||||
|
||||
if ( ! textEle.text() )
|
||||
{
|
||||
|
||||
deleteItem( checkbox );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Save edit
|
||||
textEle.text( value );
|
||||
|
||||
// Setting name
|
||||
var checkboxName = checkbox.prop( 'name' );
|
||||
var newCheckboxName = checkboxName.replace( /\[[^\]]*\]$/, '[' + value + ']' );
|
||||
|
||||
// Add [] if current level is container (can has childs)
|
||||
/// TEMP SOLUTION TO CHECK 0
|
||||
if ( li.parent().data( 'wcfe-ui-hierarchical-component-level' ) == 0 )
|
||||
{
|
||||
newCheckboxName += '[]';
|
||||
}
|
||||
|
||||
checkbox.prop( 'name', newCheckboxName );
|
||||
};
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
var inlineAddNew = function( list )
|
||||
{
|
||||
var checkbox = $( '<input type="checkbox" value="1" checked="checked" />' );
|
||||
var textEle = $( '<span></span>' );
|
||||
var li = $( '<li></li>' );
|
||||
var childList = $( '<ul class="checkbox-row wcfe-ui-hierarchical-component-level_1"></ul>' );
|
||||
var args = list.data( 'WCFECheckboxList' ).options;
|
||||
var baseName = list.parent().find( '#' + list.prop( 'id' ) + '-baseName' ).val() + '[]';
|
||||
|
||||
checkbox.prop( 'name', baseName );
|
||||
|
||||
li.append( checkbox ).append( textEle ).append( childList );
|
||||
|
||||
list.prepend( li );
|
||||
|
||||
_onedit( { target : textEle.get( 0 ) } );
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
var setListLevels = function( list, level )
|
||||
{
|
||||
|
||||
var nextLevel = level + 1;
|
||||
|
||||
// Set list level
|
||||
list.addClass( 'wcfe-ui-hierarchical-component-level_' + level );
|
||||
list.data( 'wcfe-ui-hierarchical-component-level', level );
|
||||
|
||||
// Find child lists
|
||||
list.find( '>li' ).each(
|
||||
|
||||
function()
|
||||
{
|
||||
var childList = $( this ).find( '>ul' );
|
||||
|
||||
childList.each(
|
||||
|
||||
function()
|
||||
{
|
||||
setListLevels( $( this ), nextLevel );
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$.fn.WCFECheckboxList = function( options )
|
||||
{
|
||||
|
||||
var args = $.extend(
|
||||
{
|
||||
allowNew : true,
|
||||
addNewMode : 'input',
|
||||
allowEdit : false,
|
||||
newPlaceholder : null,
|
||||
addMaxLevels : -1
|
||||
}, options );
|
||||
|
||||
// Add new item
|
||||
if ( args.allowNew )
|
||||
{
|
||||
switch ( args.addNewMode )
|
||||
{
|
||||
|
||||
case 'inline':
|
||||
|
||||
var checkboxListElement = this;
|
||||
|
||||
$( '<a href="#"></a>' ).prependTo( this )
|
||||
.addClass( 'inline-add-button' )
|
||||
.text( args.levels[ 0 ].addText )
|
||||
.click(
|
||||
|
||||
function()
|
||||
{
|
||||
|
||||
inlineAddNew( $( event.target ).next() );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// Allow adding child items to the max specified level
|
||||
addNewChildEle = $( '<a href="#" class="add-new-child"></a>' ).click( _oninlineadd );
|
||||
|
||||
this.delegate( 'li>span', 'mouseenter',
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function()
|
||||
{
|
||||
|
||||
var itemEle = $( this );
|
||||
var currentLevel = itemEle.parent().parent().data( 'wcfe-ui-hierarchical-component-level' );
|
||||
|
||||
if ( currentLevel < args.addMaxLevels )
|
||||
{
|
||||
itemEle.append( addNewChildEle.show().text( args.levels[ currentLevel + 1 ].addText ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.delegate( 'li>span', 'mouseleave',
|
||||
|
||||
function( event )
|
||||
{
|
||||
|
||||
addNewChildEle.hide();
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
this.find( '.checkbox-list-input' ).keydown( _oninputaddnew ).attr( 'placeholder', args.newPlaceholder );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete
|
||||
this.delegate( 'input:checkbox', 'change', _onunchecked );
|
||||
|
||||
// Edit
|
||||
if ( args.allowEdit )
|
||||
{
|
||||
this.find( 'li>span' ).click( _onedit );
|
||||
}
|
||||
|
||||
// Set list levels
|
||||
var rootList = this.find( '>ul' );
|
||||
setListLevels( rootList, 0 );
|
||||
|
||||
editInput = $( '<input type="text" />' ).hide().keydown( _onediting ).blur( endEdit );
|
||||
childListToggler = $( '<a class="child-items-toggler" href="#"></a>' ).hide().click(
|
||||
|
||||
function()
|
||||
{
|
||||
|
||||
var childList = childListToggler.parent().next().toggle().toggleClass( 'expanded' );
|
||||
|
||||
if ( childList.hasClass( 'expanded' ) )
|
||||
{
|
||||
childListToggler.addClass( 'expanded' );
|
||||
}
|
||||
else
|
||||
{
|
||||
childListToggler.removeClass( 'expanded' );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
// Child lists toggler
|
||||
$( this ).delegate( '>ul li', 'mouseover',
|
||||
|
||||
function()
|
||||
{
|
||||
|
||||
var itemEle = $( this );
|
||||
var list = itemEle.parent();
|
||||
var childList = itemEle.find( '>ul' );
|
||||
var currentLevel = list.data( 'wcfe-ui-hierarchical-component-level' );
|
||||
|
||||
if ( currentLevel < args.addMaxLevels )
|
||||
{
|
||||
childListToggler.prependTo( itemEle.find( '>span' ) );
|
||||
|
||||
if ( childList.hasClass( 'expanded' ) )
|
||||
{
|
||||
childListToggler.addClass( 'expanded' );
|
||||
}
|
||||
else
|
||||
{
|
||||
childListToggler.removeClass( 'expanded' );
|
||||
}
|
||||
|
||||
childListToggler.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
$( this ).delegate( '>ul li', 'mouseleave',
|
||||
|
||||
function()
|
||||
{
|
||||
childListToggler.detach();
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
// Hold supplied instances vars for later reference
|
||||
rootList.each(
|
||||
function()
|
||||
{
|
||||
$( this ).data( 'WCFECheckboxList', { options : args } );
|
||||
}
|
||||
);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
} ( jQuery ) );
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class jQueryCookies extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'jquery.cookie.js';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
namespace WCFE\Libraries\JavaScript;
|
||||
|
||||
# Script resource
|
||||
use WPPFW\Services\Queue\ScriptResource;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class jQueryMenu extends ScriptResource {
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fileName = 'jquery-menu-ui.min.js';
|
||||
|
||||
}
|
||||
6
wordpress_plugins/wp-config-file-editor/Libraries/JavaScript/jquery-menu-ui.min.js
vendored
Normal file
6
wordpress_plugins/wp-config-file-editor/Libraries/JavaScript/jquery-menu-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
wordpress_plugins/wp-config-file-editor/Libraries/JavaScript/jquery-ui.min.css
vendored
Normal file
7
wordpress_plugins/wp-config-file-editor/Libraries/JavaScript/jquery-ui.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,117 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.4.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(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 {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
|
||||
if (value !== undefined && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setTime(+t + days * 864e+5);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(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 result = key ? undefined : {};
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = parts.join('=');
|
||||
|
||||
if (key && key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return !$.cookie(key);
|
||||
};
|
||||
|
||||
}));
|
||||
Reference in New Issue
Block a user