-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
79 additions
and
80 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
*/ | ||
|
||
namespace kartik\export; | ||
|
@@ -38,6 +38,7 @@ | |
use yii\helpers\Url; | ||
use yii\web\JsExpression; | ||
use yii\web\View; | ||
use kartik\dialog\Dialog; | ||
|
||
/** | ||
* Export menu widget. Export tabular data to various formats using the PHPExcel library by reading data from a | ||
|
@@ -81,6 +82,13 @@ class ExportMenu extends GridView | |
*/ | ||
public $target = self::TARGET_POPUP; | ||
|
||
/** | ||
* @var array configuration settings for the Krajee dialog widget that will be used to render alerts and | ||
* confirmation dialog prompts | ||
* @see http://demos.krajee.com/dialog | ||
*/ | ||
public $krajeeDialogSettings = []; | ||
|
||
/** | ||
* @var bool whether to show a confirmation alert dialog before download. This confirmation dialog will notify user | ||
* about the type of exported file for download and to disable popup blockers. Defaults to `true`. | ||
|
@@ -1005,6 +1013,7 @@ protected function setDefaultExportConfig() | |
protected function registerAssets() | ||
{ | ||
$view = $this->getView(); | ||
Dialog::widget($this->krajeeDialogSettings); | ||
ExportMenuAsset::register($view); | ||
$this->messages += [ | ||
'allowPopups' => Yii::t( | ||
|
@@ -1022,6 +1031,7 @@ protected function registerAssets() | |
$options = Json::encode([ | ||
'formId' => $formId, | ||
'messages' => $this->messages, | ||
'dialogLib' => new JsExpression(ArrayHelper::getValue($this->krajeeDialogSettings, 'libName', 'krajeeDialog')) | ||
]); | ||
$menu = 'kvexpmenu_' . hash('crc32', $options); | ||
$view->registerJs("var {$menu} = {$options};\n", View::POS_HEAD); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Columns Selector Style Sheet | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Columns Selector Style Sheet | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Menu Style Sheet | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Menu Style Sheet | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Columns Selector Validation Module. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Columns Selector Validation Module. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Data Validation Module. | ||
* | ||
|
@@ -29,18 +29,7 @@ | |
'<body style="display:table-cell;font-family:Helvetica,Arial,sans-serif;color:#888;font-weight:bold;line-height:1.4em;text-align:center;vertical-align:middle;width:100%;height:100%;padding:0 10px;">' + | ||
'{msg}' + | ||
'</body>' + | ||
'</html>', | ||
kvConfirm = function (msg) { | ||
if (isEmpty(msg)) { | ||
return true; | ||
} | ||
try { | ||
return window.confirm(msg); | ||
} | ||
catch (err) { | ||
return true; | ||
} | ||
}; | ||
'</html>'; | ||
|
||
var ExportData = function (element, options) { | ||
var self = this; | ||
|
@@ -57,34 +46,6 @@ | |
|
||
ExportData.prototype = { | ||
constructor: ExportData, | ||
notify: function (e) { | ||
var self = this, msgs, msg = '', msg1, msg2, msg3; | ||
if (!self.showConfirmAlert) { | ||
e.preventDefault(); | ||
return true; | ||
} | ||
msgs = self.messages; | ||
msg1 = isEmpty(self.alertMsg) ? '' : self.alertMsg; | ||
msg2 = isEmpty(msgs.allowPopups) ? '' : msgs.allowPopups; | ||
msg3 = isEmpty(msgs.confirmDownload) ? '' : msgs.confirmDownload; | ||
if (msg1.length && msg2.length) { | ||
msg = msg1 + '\n\n' + msg2; | ||
} else { | ||
if (!msg1.length && msg2.length) { | ||
msg = msg2; | ||
} else { | ||
msg = (msg1.length && !msg2.length) ? msg1 : ''; | ||
} | ||
} | ||
if (msg3.length) { | ||
msg = msg + '\n\n' + msg3; | ||
} | ||
e.preventDefault(); | ||
if (isEmpty(msg)) { | ||
return true; | ||
} | ||
return kvConfirm(msg); | ||
}, | ||
setPopupAlert: function (msg) { | ||
var self = this; | ||
if (!self.popup.document) { | ||
|
@@ -103,10 +64,49 @@ | |
listen: function () { | ||
var self = this; | ||
self.$form.attr('action', window.location.href).appendTo('body'); | ||
self.$element.off('click').on('click', function (e) { | ||
var $selected, cols = []; | ||
if (self.notify(e)) { | ||
var fmt = $(this).data('format'); | ||
self.listenClick(); | ||
if (self.target === '_popup') { | ||
self.$form.off('submit.exportmenu').on('submit.exportmenu', function () { | ||
setTimeout(function () { | ||
self.setPopupAlert(self.messages.downloadComplete, true); | ||
}, 1000); | ||
}); | ||
} | ||
}, | ||
listenClick: function() { | ||
var self = this; | ||
self.$element.off('click.exportmenu').on('click.exportmenu', function (e) { | ||
var fmt, msgs, msg = '', msg1, msg2, msg3, lib = window[self.dialogLib]; | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (!self.showConfirmAlert) { | ||
return; | ||
} | ||
msgs = self.messages; | ||
msg1 = isEmpty(self.alertMsg) ? '' : self.alertMsg; | ||
msg2 = isEmpty(msgs.allowPopups) ? '' : msgs.allowPopups; | ||
msg3 = isEmpty(msgs.confirmDownload) ? '' : msgs.confirmDownload; | ||
if (msg1.length && msg2.length) { | ||
msg = msg1 + '\n\n' + msg2; | ||
} else { | ||
if (!msg1.length && msg2.length) { | ||
msg = msg2; | ||
} else { | ||
msg = (msg1.length && !msg2.length) ? msg1 : ''; | ||
} | ||
} | ||
if (msg3.length) { | ||
msg = msg + '\n\n' + msg3; | ||
} | ||
if (isEmpty(msg)) { | ||
return; | ||
} | ||
fmt = $(this).data('format'); | ||
lib.confirm(msg, function(result) { | ||
var $selected, cols = []; | ||
if (!result) { | ||
return; | ||
} | ||
self.$form.find('[name="export_type"]').val(fmt); | ||
if (self.target === '_popup') { | ||
self.popup = popupDialog('', 'kvExportFullDialog', 350, 120); | ||
|
@@ -124,15 +124,8 @@ | |
self.$form.find('input[name="export_columns"]').val(JSON.stringify(cols)); | ||
} | ||
self.$form.trigger('submit'); | ||
} | ||
}); | ||
if (self.target === '_popup') { | ||
self.$form.off('submit').on('submit', function () { | ||
setTimeout(function () { | ||
self.setPopupAlert(self.messages.downloadComplete, true); | ||
}, 1000); | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
|
@@ -162,6 +155,7 @@ | |
showConfirmAlert: true, | ||
columnSelectorId: null, | ||
alertMsg: '', | ||
dialogLib: 'krajeeDialog', | ||
settings: { | ||
formId: '', | ||
messages: { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
*/ | ||
|
||
use yii\helpers\Html; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Submission Form | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @package yii2-export | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 | ||
* @version 1.2.7 | ||
* @version 1.2.6 | ||
* | ||
* Export Submission View | ||
* | ||
|