mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Removed prototype.js style $() alias usage for document.getElementById() to avoid confusion with the more common jQuery() alias.
API CHANGE Removed several unsed JavaScript globals: sprintf(), Number.prototype.CURRENCIES, Number.prototype.toCurrency(), String.prototype.ucfirst(), jQuery.fn.clearFields(), jQuery.fn.clearInputs() MINOR Removed prototype_improvements.js and jquery_improvements.js files, now contained in individual component code (or removed altogether)
This commit is contained in:
parent
0e3e2904a4
commit
5911abc0f6
@ -230,9 +230,7 @@ class LeftAndMain extends Controller {
|
||||
Requirements::combine_files(
|
||||
'lib.js',
|
||||
array(
|
||||
SAPPHIRE_DIR . '/javascript/prototype_improvements.js',
|
||||
THIRDPARTY_DIR . '/jquery/jquery.js',
|
||||
SAPPHIRE_DIR . '/javascript/jquery_improvements.js',
|
||||
THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js',
|
||||
SAPPHIRE_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js',
|
||||
THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js',
|
||||
|
@ -152,7 +152,6 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-livequery/jquery.livequery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery/jquery_improvements.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.History.js');
|
||||
}
|
||||
|
@ -187,7 +187,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/screen.css');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/MemberImportForm.css');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/MemberImportForm.js');
|
||||
@ -219,7 +218,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/screen.css');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/MemberImportForm.css');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/MemberImportForm.js');
|
||||
|
@ -1,3 +1,5 @@
|
||||
jQuery.noConflict();
|
||||
|
||||
/**
|
||||
* File: LeftAndMain.js
|
||||
*/
|
||||
|
@ -108,6 +108,17 @@ this usually won't have any effect on your own code (unless you're including dir
|
||||
For any other files (CSS files, templates, images, JavaScript) which might
|
||||
be referenced by their path, please doublecheck that their path is still valid.
|
||||
|
||||
### Removed prototype.js and and behaviour.js dependencies from most core components
|
||||
|
||||
This will only affect you if you used either of those libraries,
|
||||
or by extension on the globals set in `prototype_improvements.js` and `jquery_improvements.js`.
|
||||
The `$$()` shorthand for `document.getElementsBySelector()` is no longer globally bound,
|
||||
but rather just defined when used through other components. The `$()` shorthand
|
||||
had two meanings, based on context: Either `document.getElementsById()` through prototype.js,
|
||||
or as an alias for the `jQuery()` method. In general, we recommend not to rely on
|
||||
the `$()` global in SilverStripe, as we unset it via `[jQuery.noConflict()](http://api.jquery.com/jQuery.noConflict/)`.
|
||||
Use a [custom alias via function scope](http://api.jquery.com/jQuery.noConflict/#example-1) if possible.
|
||||
|
||||
### Moved `Translatable` extension into new 'translatable' module ###
|
||||
|
||||
If you are translating your `SiteTree` or `DataObject` classes with the `Translatable`
|
||||
|
@ -211,7 +211,7 @@ class ComplexTableField extends TableListField {
|
||||
*/
|
||||
function FieldHolder() {
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/behaviour/behaviour.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
@ -844,7 +844,6 @@ class ComplexTableField_Popup extends Form {
|
||||
Requirements::css(CMS_DIR . '/css/cms_right.css');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/scriptaculous/scriptaculous.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/scriptaculous/scriptaculous/controls.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
|
@ -596,7 +596,6 @@ class DateField_View_JQuery {
|
||||
function onAfterRender($html) {
|
||||
if($this->getField()->getConfig('showcalendar')) {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
|
||||
|
@ -71,7 +71,6 @@ class TabSet extends CompositeField {
|
||||
*/
|
||||
public function FieldHolder() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/jquery_improvements.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js');
|
||||
|
||||
|
@ -468,8 +468,8 @@ class TableField extends TableListField {
|
||||
*/
|
||||
function FieldHolder() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
|
||||
|
@ -278,7 +278,6 @@ class TableListField extends FormField {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
|
||||
|
@ -25,7 +25,6 @@ class ToggleCompositeField extends CompositeField {
|
||||
public function FieldHolder() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
|
@ -51,7 +51,6 @@ class ToggleField extends ReadonlyField {
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleField.js");
|
||||
|
||||
if($this->startClosed) $this->addExtraClass('startClosed');
|
||||
|
@ -146,7 +146,6 @@ class TreeDropdownField extends FormField {
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jstree/jquery.jstree.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeDropdownField.js');
|
||||
|
@ -82,7 +82,6 @@ class TreeMultiselectField extends TreeDropdownField {
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jstree/jquery.jstree.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TreeDropdownField.js');
|
||||
|
@ -317,7 +317,6 @@ class UploadField extends FileField {
|
||||
}
|
||||
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/i18n.js');
|
||||
|
@ -182,7 +182,6 @@ abstract class Validator extends Object {
|
||||
if($this->getJavascriptValidationHandler() == 'prototype') {
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/Validator.js");
|
||||
|
||||
|
@ -56,7 +56,6 @@ class GridFieldRelationAdd implements GridField_HTMLProvider, GridField_ActionPr
|
||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/GridFieldSearch.js");
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
||||
|
||||
GB_OpenerObj = {};
|
||||
GB_RefreshLink = "";
|
||||
|
||||
@ -45,8 +48,8 @@ ComplexTableField.prototype = {
|
||||
|
||||
setPopupSize: function() {
|
||||
try {
|
||||
this.popupHeight = parseInt($(this.id + '_PopupHeight').value);
|
||||
this.popupWidth = parseInt($(this.id + '_PopupWidth').value);
|
||||
this.popupHeight = parseInt(document.getElementById(this.id + '_PopupHeight').value);
|
||||
this.popupWidth = parseInt(document.getElementById(this.id + '_PopupWidth').value);
|
||||
} catch (ex) {
|
||||
this.popupHeight = this.defaultPopupHeight;
|
||||
this.popupWidth = this.defaultPopupWidth;
|
||||
@ -143,3 +146,11 @@ ComplexTableField.prototype = {
|
||||
}
|
||||
|
||||
ComplexTableField.applyTo('div.ComplexTableField');
|
||||
|
||||
/**
|
||||
* Get first letter as uppercase
|
||||
*/
|
||||
String.prototype.ucfirst = function () {
|
||||
var firstLetter = this.substr(0,1).toUpperCase()
|
||||
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
|
||||
}
|
@ -63,7 +63,7 @@ HasManyFileFieldUploadButton.prototype = {
|
||||
initialize: function() {
|
||||
this.upload = new Upload({
|
||||
fileUploadLimit : '6',
|
||||
securityID : $('SecurityID').value,
|
||||
securityID : document.getElementById('SecurityID').value,
|
||||
beginUploadOnQueue : true,
|
||||
fileQueued : this.uploadFileQueuedCallback.bind(this),
|
||||
fileComplete : this.uploadFileCompleteCallback.bind(this),
|
||||
|
@ -4,7 +4,7 @@
|
||||
Behaviour.register({
|
||||
'div.inlineformaction input#$ID': {
|
||||
onclick: function() {
|
||||
var url = jQuery('base').attr('href') + 'admin-custom/' + this.name.substring(7) + '?ID=' + $('Form_EditForm_ID').value + '&ajax=1';
|
||||
var url = jQuery('base').attr('href') + 'admin-custom/' + this.name.substring(7) + '?ID=' + jQuery('#Form_EditForm_ID').value + '&ajax=1';
|
||||
|
||||
jQuery.ajax({
|
||||
'url': url,
|
||||
|
@ -1,12 +1,12 @@
|
||||
Behaviour.register({
|
||||
'input#Form_EditForm_ExternalURL': {
|
||||
onclick: function() {
|
||||
$('Form_EditForm_RedirectionType_External').checked = true;
|
||||
document.getElementById('Form_EditForm_RedirectionType_External').checked = true;
|
||||
}
|
||||
},
|
||||
'#TreeDropdownField_Form_EditForm_LinkToID': {
|
||||
onclick: function() {
|
||||
$('Form_EditForm_RedirectionType_Internal').checked = true;
|
||||
document.getElementById('Form_EditForm_RedirectionType_Internal').checked = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
Event.observe( window, 'load', function() {
|
||||
if($('sitetree')){
|
||||
if(typeof $('sitetree').observeMethod != 'undefined') {
|
||||
$('sitetree').observeMethod( 'NodeClicked' , function() {
|
||||
if(document.getElementById('sitetree')){
|
||||
if(typeof document.getElementById('sitetree').observeMethod != 'undefined') {
|
||||
document.getElementById('sitetree').observeMethod( 'NodeClicked' , function() {
|
||||
checkedListNameArray = null;
|
||||
checkedArray = null;
|
||||
} );
|
||||
|
@ -68,7 +68,7 @@ TableField.prototype = {
|
||||
jQuery.ajax({
|
||||
'url': link.getAttribute("href"),
|
||||
'method': 'post',
|
||||
'data': {ajax: 1, 'SecurityID': $('SecurityID') ? $('SecurityID').value : null},
|
||||
'data': {ajax: 1, 'SecurityID': document.getElementById('SecurityID') ? document.getElementById('SecurityID').value : null},
|
||||
'success': function(response){
|
||||
jQuery(row).fadeOut('fast', function() {
|
||||
// remove row from DOM
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
||||
|
||||
TableListField = Class.create();
|
||||
TableListField.prototype = {
|
||||
|
||||
@ -116,7 +119,7 @@ TableListField.prototype = {
|
||||
},
|
||||
|
||||
removeById: function(id) {
|
||||
var el =$('record-' + this.id + '-' + id);
|
||||
var el = jQuery('#record-' + this.id + '-' + id)[0];
|
||||
if(el) el.parentNode.removeChild(el);
|
||||
this._summarise();
|
||||
},
|
||||
@ -134,7 +137,7 @@ TableListField.prototype = {
|
||||
this.unmarkAll();
|
||||
}else{
|
||||
this.unmarkAll();
|
||||
var records = $$('#' + this.id + ' td.' + el.rel + ' input.checkbox');
|
||||
var records = jQuery('#' + this.id + ' td.' + el.rel + ' input.checkbox');
|
||||
var i=0;
|
||||
for(i; i<records.length; i++){
|
||||
records[i].checked = 'checked';
|
||||
@ -172,7 +175,7 @@ TableListField.prototype = {
|
||||
var el = Event.element(e);
|
||||
if(el.nodeName != "a") el = Event.findElement(e,"a");
|
||||
} else {
|
||||
var el = $(this.id);
|
||||
var el = jQuery('#' + this.id)[0];
|
||||
}
|
||||
|
||||
if(el.getAttribute('href')) {
|
||||
@ -183,7 +186,7 @@ TableListField.prototype = {
|
||||
jQuery('#' + self.id).replaceWith(response)
|
||||
// reapply behaviour and reattach methods to TF container node
|
||||
// e.g. <div class="TableListField">
|
||||
Behaviour.apply($(self.id), true);
|
||||
Behaviour.apply(jQuery('#' + self.id)[0], true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -323,7 +326,7 @@ TableListRecord.prototype = {
|
||||
this.parentNode.selectedRow = this;
|
||||
Element.addClassName(this,'current');
|
||||
|
||||
this.subform = $(subform);
|
||||
this.subform = document.getElementById(subform);
|
||||
Element.addClassName(this, 'loading');
|
||||
statusMessage('loading');
|
||||
jQuery.ajax({
|
||||
@ -353,3 +356,22 @@ TableListRecord.prototype = {
|
||||
|
||||
TableListRecord.applyTo('div.TableListField tr');
|
||||
TableListField.applyTo('div.TableListField');
|
||||
|
||||
Number.prototype.CURRENCIES = {
|
||||
en_GB: '$ ###,###.##'
|
||||
};
|
||||
|
||||
/**
|
||||
* Caution: Not finished!
|
||||
* @param iso string (Not used) Please use in combination with Number.CURRENCIES to achieve i18n
|
||||
* @return string
|
||||
*
|
||||
* @see http://www.jibbering.com/faq/faq_notes/type_convert.html
|
||||
* @see http://www.rgagnon.com/jsdetails/js-0063.html
|
||||
* @see http://www.mredkj.com/javascript/nfdocs.html
|
||||
*/
|
||||
Number.prototype.toCurrency = function(iso) {
|
||||
if(!iso) iso = SS_DEFAULT_ISO;
|
||||
// TODO stub, please implement properly
|
||||
return "$" + this.toFixed(2);
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
||||
|
||||
var ToggleCompositeField = Class.create();
|
||||
ToggleCompositeField.prototype = {
|
||||
initialize: function() {
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
||||
|
||||
var ToggleField = Class.create();
|
||||
ToggleField.prototype = {
|
||||
initialize: function() {
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") $$ = document.getElementsBySelector;
|
||||
|
||||
var _CURRENT_FORM;
|
||||
var _FIRST_ERRORED_FIELD = null;
|
||||
var _VALIDATIONS_REF = new Array();
|
||||
@ -74,7 +77,7 @@ function require(fieldName,cachedError) {
|
||||
|
||||
var descendants = _CURRENT_FORM.getElementsByTagName('*');
|
||||
|
||||
el = $(fieldName);
|
||||
el = document.getElementById(fieldName);
|
||||
|
||||
if(el == null)
|
||||
return true;
|
||||
@ -226,7 +229,7 @@ function findParentLabel(el) {
|
||||
*/
|
||||
function validationError(field,message, messageClass, cacheError) {
|
||||
if(typeof(field) == 'string') {
|
||||
field = $(field);
|
||||
field = document.getElementById(field);
|
||||
}
|
||||
|
||||
if(cacheError) {
|
||||
|
34
javascript/jquery_improvements.js
vendored
34
javascript/jquery_improvements.js
vendored
@ -1,34 +0,0 @@
|
||||
// play nice with prototype
|
||||
jQuery.noConflict();
|
||||
|
||||
/**
|
||||
* Clears the selected form elements. Takes the following actions on the matched elements:
|
||||
* - input text fields will have their 'value' property set to the empty string
|
||||
* - select elements will have their 'selectedIndex' property set to -l. Normann change it from -1 to '',
|
||||
* since set to -1, actually is not clearing the field, it change its value to null, and when submit the form the field belonged to,
|
||||
* the field value will be treated to a pure string "null", and this is not what it suppose to do.
|
||||
* - checkbox and radio inputs will have their 'checked' property set to false
|
||||
* - inputs of type submit, button, reset, and hidden will *not* be effected
|
||||
* - button elements will *not* be effected
|
||||
*
|
||||
* @example $('.myInputs').clearFields();
|
||||
* @desc Clears all inputs with class myInputs
|
||||
*
|
||||
* @name clearFields
|
||||
* @type jQuery
|
||||
* @cat Plugins/Form
|
||||
*/
|
||||
(function($) {
|
||||
$.fn.clearFields = $.fn.clearInputs = function() {
|
||||
return this.each(function() {
|
||||
var t = this.type, tag = this.tagName.toLowerCase();
|
||||
if (t == 'text' || t == 'password' || tag == 'textarea')
|
||||
this.value = '';
|
||||
else if (t == 'checkbox' || t == 'radio')
|
||||
this.checked = false;
|
||||
else if (tag == 'select')
|
||||
//changed by Normann@silvestripe.com, see document above
|
||||
this.selectedIndex = '';
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
94
javascript/prototype_improvements.js
vendored
94
javascript/prototype_improvements.js
vendored
@ -1,94 +0,0 @@
|
||||
/**
|
||||
* Additions and improvements to Prototype-code.
|
||||
* Some if this is legacy code which is now present in Prototype as well,
|
||||
* but has to be kept for older scripts.
|
||||
*
|
||||
* @author Silverstripe Ltd., http://silverstripe.com
|
||||
*/
|
||||
|
||||
// Shortcut-function (until we update to Prototye v1.5)
|
||||
if(typeof $$ != "Function") {
|
||||
$$ = document.getElementsBySelector;
|
||||
}
|
||||
|
||||
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
|
||||
function sprintf()
|
||||
{
|
||||
if (!arguments || arguments.length < 1 || !RegExp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var str = arguments[0];
|
||||
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
|
||||
var a = b = [], numSubstitutions = 0, numMatches = 0;
|
||||
while (a = re.exec(str))
|
||||
{
|
||||
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
|
||||
var pPrecision = a[5], pType = a[6], rightPart = a[7];
|
||||
|
||||
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
|
||||
|
||||
numMatches++;
|
||||
if (pType == '%')
|
||||
{
|
||||
subst = '%';
|
||||
}
|
||||
else
|
||||
{
|
||||
numSubstitutions++;
|
||||
if (numSubstitutions >= arguments.length)
|
||||
{
|
||||
//alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
|
||||
}
|
||||
var param = arguments[numSubstitutions];
|
||||
var pad = '';
|
||||
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
|
||||
else if (pPad) pad = pPad;
|
||||
var justifyRight = true;
|
||||
if (pJustify && pJustify === "-") justifyRight = false;
|
||||
var minLength = -1;
|
||||
if (pMinLength) minLength = parseInt(pMinLength);
|
||||
var precision = -1;
|
||||
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
|
||||
var subst = param;
|
||||
if (pType == 'b') subst = parseInt(param).toString(2);
|
||||
else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
|
||||
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
|
||||
else if (pType == 'u') subst = Math.abs(param);
|
||||
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
|
||||
else if (pType == 'o') subst = parseInt(param).toString(8);
|
||||
else if (pType == 's') subst = param;
|
||||
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
|
||||
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
|
||||
}
|
||||
str = leftpart + subst + rightPart;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
Number.prototype.CURRENCIES = {
|
||||
en_GB: '$ ###,###.##'
|
||||
};
|
||||
|
||||
/**
|
||||
* Caution: Not finished!
|
||||
* @param iso string (Not used) Please use in combination with Number.CURRENCIES to achieve i18n
|
||||
* @return string
|
||||
*
|
||||
* @see http://www.jibbering.com/faq/faq_notes/type_convert.html
|
||||
* @see http://www.rgagnon.com/jsdetails/js-0063.html
|
||||
* @see http://www.mredkj.com/javascript/nfdocs.html
|
||||
*/
|
||||
Number.prototype.toCurrency = function(iso) {
|
||||
if(!iso) iso = SS_DEFAULT_ISO;
|
||||
// TODO stub, please implement properly
|
||||
return "$" + this.toFixed(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first letter as uppercase
|
||||
*/
|
||||
String.prototype.ucfirst = function () {
|
||||
var firstLetter = this.substr(0,1).toUpperCase()
|
||||
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
|
||||
}
|
@ -371,7 +371,6 @@ class Security extends Controller {
|
||||
$link_base = Director::absoluteURL($this->Link("login"));
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/jquery_improvements.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
|
Loading…
Reference in New Issue
Block a user