-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
303 additions
and
257 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 +3,24 @@ | |
/** | ||
* @package yii2-detail-view | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016 | ||
* @version 1.7.4 | ||
*/ | ||
|
||
namespace kartik\detail; | ||
|
||
use kartik\base\AssetBundle; | ||
|
||
/** | ||
* Asset bundle for DetailView Widget | ||
* | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @since 1.0 | ||
*/ | ||
class DetailViewAsset extends \kartik\base\AssetBundle | ||
class DetailViewAsset extends AssetBundle | ||
{ | ||
/** | ||
* @inherit doc | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
|
@@ -27,5 +29,4 @@ public function init() | |
$this->setupAssets('css', ['css/kv-detail-view']); | ||
parent::init(); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/*! | ||
* @package yii2-detail-view | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016 | ||
* @version 1.7.4 | ||
* | ||
* Styles for yii2-detail-view extension | ||
* | ||
* Author: Kartik Visweswaran | ||
* Copyright: 2014 - 2015, Kartik Visweswaran, Krajee.com | ||
* Copyright: 2014 - 2016, Kartik Visweswaran, Krajee.com | ||
* For more JQuery plugins visit http://plugins.krajee.com | ||
* For more Yii related demos visit http://demos.krajee.com | ||
*/ | ||
|
@@ -30,13 +30,14 @@ | |
background: #ffffff url('../img/loading.gif') top 15px right 15px no-repeat; | ||
} | ||
|
||
.kv-detail-loading * { | ||
.kv-detail-loading * { | ||
background: transparent !important; | ||
} | ||
|
||
.kv-detail-loading td { | ||
border-color: #efefef !important; | ||
} | ||
|
||
.kv-edit-mode .kv-detail-view { | ||
overflow-y: hidden; | ||
} | ||
|
@@ -46,7 +47,7 @@ | |
} | ||
|
||
.kv-edit-mode table { | ||
overflow:hidden; | ||
overflow: hidden; | ||
} | ||
|
||
.kv-child-table { | ||
|
@@ -55,8 +56,8 @@ | |
|
||
.kv-child-table-row, .kv-child-table-row > td { | ||
vertical-align: middle; | ||
padding: 0!important; | ||
margin: 0!important; | ||
padding: 0 !important; | ||
margin: 0 !important; | ||
} | ||
|
||
.kv-child-table-cell { | ||
|
@@ -66,22 +67,30 @@ | |
overflow: hidden; | ||
} | ||
|
||
.kv-child-table-row th { | ||
border-left: 1px #ddd solid; | ||
border-right: 1px #ddd solid; | ||
} | ||
|
||
.kv-child-table td, .kv-child-table th { | ||
margin: 0; | ||
background: transparent; | ||
|
||
} | ||
|
||
.table .kv-child-table > tbody > tr > td, .table .kv-child-table > tbody > tr > th { | ||
padding: 8px; | ||
background: transparent; | ||
} | ||
|
||
.kv-child-table-row th { | ||
border-left: 1px #ddd solid; | ||
border-right: 1px #ddd solid; | ||
.table-condensed .kv-child-table > tbody > tr > td, .table-condensed .kv-child-table > tbody > tr > th { | ||
padding: 5px; | ||
} | ||
|
||
.kv-action-btn { | ||
margin:0 2px; | ||
padding:0 5px; | ||
background:none; | ||
border:none; | ||
margin: 0 2px; | ||
padding: 0 5px; | ||
background: none; | ||
border: none; | ||
font-size: 16px; | ||
} | ||
|
||
|
@@ -90,41 +99,41 @@ | |
} | ||
|
||
.panel-primary .kv-action-btn { | ||
color:#d9edf7; | ||
color: #d9edf7; | ||
} | ||
|
||
.panel-primary .kv-action-btn:hover { | ||
color:#c4e3f3; | ||
color: #c4e3f3; | ||
} | ||
|
||
.panel-info .kv-action-btn { | ||
color:#31708f; | ||
color: #31708f; | ||
} | ||
|
||
.panel-info .kv-action-btn:hover { | ||
color:#245269; | ||
color: #245269; | ||
} | ||
|
||
.panel-warning .kv-action-btn { | ||
color:#8a6d3b; | ||
color: #8a6d3b; | ||
} | ||
|
||
.panel-warning .kv-action-btn:hover { | ||
color:#66512c; | ||
color: #66512c; | ||
} | ||
|
||
.panel-danger .kv-action-btn { | ||
color:#a94442; | ||
color: #a94442; | ||
} | ||
|
||
.panel-danger .kv-action-btn:hover { | ||
color:#843534; | ||
color: #843534; | ||
} | ||
|
||
.panel-success .kv-action-btn { | ||
color:#3c763d; | ||
color: #3c763d; | ||
} | ||
|
||
.panel-success .kv-action-btn:hover { | ||
color:#2b542c; | ||
color: #2b542c; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,26 @@ | ||
/*! | ||
* @package yii2-detail-view | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016 | ||
* @version 1.7.4 | ||
* | ||
* Client extension for the yii2-detail-view extension | ||
* | ||
* Author: Kartik Visweswaran | ||
* Copyright: 2014 - 2015, Kartik Visweswaran, Krajee.com | ||
* Copyright: 2014 - 2016, Kartik Visweswaran, Krajee.com | ||
* For more JQuery plugins visit http://plugins.krajee.com | ||
* For more Yii related demos visit http://demos.krajee.com | ||
*/ | ||
|
||
(function ($) { | ||
"use strict"; | ||
|
||
var NAMESPACE, events; | ||
NAMESPACE = '.kvDetailView'; | ||
events = { | ||
click: 'click' + NAMESPACE, | ||
afterValidate: 'afterValidate' + NAMESPACE | ||
}; | ||
|
||
var KvDetailView = function (element, options) { | ||
var self = this; | ||
self.$element = $(element); | ||
|
@@ -31,7 +37,7 @@ | |
self.initElements(); | ||
self.listen(); | ||
}, | ||
alert: function(type, msg) { | ||
alert: function (type, msg) { | ||
var self = this, css; | ||
css = self.alertMessageSettings[type]; | ||
if (msg) { | ||
|
@@ -41,49 +47,58 @@ | |
return ''; | ||
}, | ||
initAlert: function () { | ||
var self = this, $alert = self.$element.find('.kv-alert-container'); | ||
$alert.find('.alert .close').each(function() { | ||
var self = this, $alert = self.$element.find('.kv-alert-container'), eClick = events.click; | ||
$alert.find('.alert .close').each(function () { | ||
var $el = $(this); | ||
$el.off('click').on('click', function() { | ||
setTimeout(function() { | ||
if (!$alert.find('.alert').length) { | ||
$el.off(eClick).on(eClick, function () { | ||
setTimeout(function () { | ||
if (!$alert.find('.alert').length) { | ||
$alert.hide(); | ||
} | ||
}, 300); | ||
}); | ||
}); | ||
}); | ||
}, | ||
destroy: function () { | ||
var self = this, eClick = events.click, eValidate = events.afterValidate; | ||
self.$btnSave.off(eClick); | ||
self.$btnUpdate.off(eClick); | ||
self.$btnView.off(eClick); | ||
self.$btnDelete.off(eClick); | ||
self.$element.find('.kv-detail-view').closest('form').off(eValidate); | ||
self.$element.find('.kv-alert-container .alert .close').off(eClick); | ||
}, | ||
listen: function () { | ||
var self = this, $alert = self.$element.find('.kv-alert-container'), | ||
$detail = self.$element.find('.kv-detail-view'); | ||
$detail.closest('form').on('afterValidate', function (event, messages) { | ||
var self = this, $alert = self.$element.find('.kv-alert-container'), eClick = events.click, | ||
eValidate = events.afterValidate, $detail = self.$element.find('.kv-detail-view'); | ||
$detail.closest('form').off(eValidate).on(eValidate, function (event, messages) { | ||
if (messages !== undefined) { | ||
$detail.removeClass('kv-detail-loading'); | ||
} | ||
}); | ||
self.$btnSave.on('click', function () { | ||
self.$btnSave.off(eClick).on(eClick, function () { | ||
$alert.hide(); | ||
$detail.removeClass('kv-detail-loading').addClass('kv-detail-loading'); | ||
}); | ||
self.$btnUpdate.on('click', function () { | ||
self.$btnUpdate.off(eClick).on(eClick, function () { | ||
self.setMode('edit'); | ||
}); | ||
self.$btnView.on('click', function () { | ||
self.$btnView.off(eClick).on(eClick, function () { | ||
self.setMode('view'); | ||
}); | ||
self.$btnDelete.on('click', function (ev) { | ||
var $el = $(this), params = self.deleteParams, confirmMsg = self.deleteConfirm, | ||
settings = self.deleteAjaxSettings || {}; | ||
self.$btnDelete.off(eClick).on(eClick, function (ev) { | ||
var $el = $(this), params = self.deleteParams, confirmMsg = self.deleteConfirm, | ||
settings = self.deleteAjaxSettings || {}; | ||
ev.preventDefault(); | ||
if (confirmMsg && !confirm(confirmMsg)) { | ||
if (confirmMsg && !confirm(confirmMsg)) { | ||
return; | ||
} | ||
settings = $.extend({ | ||
type: 'post', | ||
dataType: 'json', | ||
data: params, | ||
url: $el.attr('href'), | ||
beforeSend: function() { | ||
beforeSend: function () { | ||
$alert.html('').hide(); | ||
$detail.removeClass('kv-detail-loading').addClass('kv-detail-loading'); | ||
}, | ||
|
@@ -94,20 +109,21 @@ | |
self.$btnUpdate.attr('disabled', 'disabled'); | ||
self.$btnView.attr('disabled', 'disabled'); | ||
self.$btnSave.attr('disabled', 'disabled'); | ||
}; | ||
$.each(data.messages, function(key, msg) { | ||
} | ||
$.each(data.messages, function (key, msg) { | ||
$alert.append(self.alert(key, msg)); | ||
}); | ||
$alert.hide().fadeIn('slow', function() { | ||
$detail.removeClass('kv-detail-loading'); | ||
self.initAlert(); | ||
$alert.hide().fadeIn('slow', function () { | ||
$detail.removeClass('kv-detail-loading'); | ||
self.initAlert(); | ||
}); | ||
}, | ||
error: function(xhr, txt, err) { | ||
error: function (xhr, txt, err) { | ||
var msg = ''; | ||
if (self.showErrorStack) { | ||
msg = xhr.responseText ? $(xhr.responseText).text() : ''; | ||
msg = msg && msg.length ? '<pre>' + $.trim(msg).replace(/\n\s*\n/g, '\n').replace(/\</g, '<') + '</pre>' : ''; | ||
msg = msg && msg.length ? '<pre>' + $.trim(msg).replace(/\n\s*\n/g, '\n') | ||
.replace(/</g, '<') + '</pre>' : ''; | ||
} | ||
msg = self.alert('kv-detail-error', err + msg); | ||
$detail.removeClass('kv-detail-loading'); | ||
|
Oops, something went wrong.