Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b4c4b405
Commit
b4c4b405
authored
Sep 06, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3511: Dropped `yii.allowAction()` and modified `yii.confirm()` in…
Fixes #3511: Dropped `yii.allowAction()` and modified `yii.confirm()` in `yii.js` to support callbacks
parent
1a8dd259
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
39 deletions
+28
-39
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
yii.js
framework/assets/yii.js
+27
-39
No files found.
framework/CHANGELOG.md
View file @
b4c4b405
...
...
@@ -225,6 +225,7 @@ Yii Framework 2 Change Log
-
Chg #3175: InvalidCallException, InvalidParamException, UnknownMethodException are now extended from SPL BadMethodCallException (samdark)
-
Chg #3358: Removed automatic CSRF meta tag generation by
`View`
. Added
`Html::csrfMetaTags()`
and its call to main layout files (qiangxue)
-
Chg #3383: Added
`$type`
parameter to
`IdentityInterface::findIdentityByAccessToken()`
(qiangxue)
-
Chg #3511: Dropped
`yii.allowAction()`
and modified
`yii.confirm()`
in
`yii.js`
to support callbacks (tanakahisateru)
-
Chg #3531:
\y
ii
\g
rid
\G
ridView now allows any character (except ":") in the attribute part of the shorthand syntax for columns (rawtaz)
-
Chg #3544: Added
`$key`
as a parameter to the callable specified via
`yii\grid\DataColumn::value`
(mdmunir)
-
Chg #3611: Query caching is refactored. (qiangxue)
...
...
framework/assets/yii.js
View file @
b4c4b405
...
...
@@ -98,23 +98,15 @@ yii = (function ($) {
* The default implementation simply displays a js confirmation dialog.
* You may override this by setting `yii.confirm`.
* @param message the confirmation message.
* @return boolean whether the user confirms with the message in the dialog
* @param ok a callback to be called when the user confirms the message
* @param cancel a callback to be called when the user cancels the confirmation
*/
confirm
:
function
(
message
)
{
return
confirm
(
message
);
},
/**
* Returns a value indicating whether to allow executing the action defined for the specified element.
* This method recognizes the `data-confirm` attribute of the element and uses it
* as the message in a confirmation dialog. The method will return true if this special attribute
* is not defined or if the user confirms the message.
* @param $e the jQuery representation of the element
* @return boolean whether to allow executing the action defined for the specified element.
*/
allowAction
:
function
(
$e
)
{
var
message
=
$e
.
data
(
'confirm'
);
return
message
===
undefined
||
pub
.
confirm
(
message
);
confirm
:
function
(
message
,
ok
,
cancel
)
{
if
(
confirm
(
message
))
{
!
ok
||
ok
();
}
else
{
!
cancel
||
cancel
();
}
},
/**
...
...
@@ -126,15 +118,14 @@ yii = (function ($) {
* For other elements, either the containing form action or the current page URL will be used
* as the form action URL.
*
* If the `data-method` attribute is not defined,
the default element action will be performed
.
* If the `data-method` attribute is not defined,
nothing will be done
.
*
* @param $e the jQuery representation of the element
* @return boolean whether to execute the default action for the element.
*/
handleAction
:
function
(
$e
)
{
var
method
=
$e
.
data
(
'method'
);
if
(
method
===
undefined
)
{
return
true
;
return
;
}
var
$form
=
$e
.
closest
(
'form'
);
...
...
@@ -178,8 +169,6 @@ yii = (function ($) {
if
(
newForm
)
{
$form
.
remove
();
}
return
false
;
},
getQueryParams
:
function
(
url
)
{
...
...
@@ -237,28 +226,27 @@ yii = (function ($) {
}
function
initDataMethods
()
{
var
$document
=
$
(
document
);
// handle data-confirm and data-method for clickable elements
$document
.
on
(
'click.yii'
,
pub
.
clickableSelector
,
function
(
event
)
{
var
handler
=
function
(
event
)
{
var
$this
=
$
(
this
);
if
(
pub
.
allowAction
(
$this
))
{
return
pub
.
handleAction
(
$this
);
}
else
{
event
.
stopImmediatePropagation
();
return
false
;
// data-confirm requires data-method
if
(
$this
.
data
(
'method'
)
===
undefined
)
{
return
true
;
}
});
// handle data-confirm and data-method for changeable elements
$document
.
on
(
'change.yii'
,
pub
.
changeableSelector
,
function
(
event
)
{
var
$this
=
$
(
this
);
if
(
pub
.
allowAction
(
$this
))
{
return
pub
.
handleAction
(
$this
);
var
message
=
$this
.
data
(
'confirm'
);
if
(
message
!==
undefined
)
{
pub
.
confirm
(
message
,
function
()
{
pub
.
handleAction
(
$this
);
});
}
else
{
event
.
stopImmediatePropagation
();
return
false
;
pub
.
handleAction
(
$this
);
}
});
event
.
stopImmediatePropagation
();
return
false
;
};
// handle data-confirm and data-method for clickable and changeable elements
$
(
document
).
on
(
'click.yii'
,
pub
.
clickableSelector
,
handler
)
.
on
(
'change.yii'
,
pub
.
changeableSelector
,
handler
);
}
function
initScriptFilter
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment