2015-08-18 00:00:26 +00:00
/ * *
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
* https : //www.drupal.org/node/2815083
* @ preserve
* * /
2015-08-18 00:00:26 +00:00
( function ( $ , Drupal ) {
Drupal . quickedit . util = Drupal . quickedit . util || { } ;
Drupal . quickedit . util . constants = { } ;
2015-10-22 04:44:50 +00:00
Drupal . quickedit . util . constants . transitionEnd = 'transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit' ;
2015-08-18 00:00:26 +00:00
Drupal . quickedit . util . buildUrl = function ( id , urlFormat ) {
var parts = id . split ( '/' ) ;
return Drupal . formatString ( decodeURIComponent ( urlFormat ) , {
'!entity_type' : parts [ 0 ] ,
'!id' : parts [ 1 ] ,
'!field_name' : parts [ 2 ] ,
'!langcode' : parts [ 3 ] ,
'!view_mode' : parts [ 4 ]
} ) ;
} ;
Drupal . quickedit . util . networkErrorModal = function ( title , message ) {
var $message = $ ( '<div>' + message + '</div>' ) ;
var networkErrorModal = Drupal . dialog ( $message . get ( 0 ) , {
title : title ,
dialogClass : 'quickedit-network-error' ,
2018-11-23 12:29:20 +00:00
buttons : [ {
text : Drupal . t ( 'OK' ) ,
click : function click ( ) {
networkErrorModal . close ( ) ;
} ,
primary : true
} ] ,
create : function create ( ) {
2015-08-18 00:00:26 +00:00
$ ( this ) . parent ( ) . find ( '.ui-dialog-titlebar-close' ) . remove ( ) ;
} ,
2018-11-23 12:29:20 +00:00
close : function close ( event ) {
2015-08-18 00:00:26 +00:00
$ ( event . target ) . remove ( ) ;
}
} ) ;
networkErrorModal . showModal ( ) ;
} ;
Drupal . quickedit . util . form = {
2018-11-23 12:29:20 +00:00
load : function load ( options , callback ) {
2015-08-18 00:00:26 +00:00
var fieldID = options . fieldID ;
var formLoaderAjax = Drupal . ajax ( {
url : Drupal . quickedit . util . buildUrl ( fieldID , Drupal . url ( 'quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode' ) ) ,
submit : {
nocssjs : options . nocssjs ,
reset : options . reset
} ,
2018-11-23 12:29:20 +00:00
error : function error ( xhr , url ) {
2015-08-18 00:00:26 +00:00
var fieldLabel = Drupal . quickedit . metadata . get ( fieldID , 'label' ) ;
2018-11-23 12:29:20 +00:00
var message = Drupal . t ( 'Could not load the form for <q>@field-label</q>, either due to a website problem or a network connection problem.<br>Please try again.' , { '@field-label' : fieldLabel } ) ;
2015-10-08 18:40:12 +00:00
Drupal . quickedit . util . networkErrorModal ( Drupal . t ( 'Network problem!' ) , message ) ;
2015-08-18 00:00:26 +00:00
var fieldModel = Drupal . quickedit . app . model . get ( 'activeField' ) ;
fieldModel . set ( 'state' , 'candidate' ) ;
}
} ) ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
formLoaderAjax . commands . quickeditFieldForm = function ( ajax , response , status ) {
callback ( response . data , ajax ) ;
Drupal . ajax . instances [ this . instanceIndex ] = null ;
} ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
formLoaderAjax . execute ( ) ;
} ,
2018-11-23 12:29:20 +00:00
ajaxifySaving : function ajaxifySaving ( options , $submit ) {
2015-08-18 00:00:26 +00:00
var settings = {
url : $submit . closest ( 'form' ) . attr ( 'action' ) ,
setClick : true ,
event : 'click.quickedit' ,
progress : false ,
submit : {
nocssjs : options . nocssjs ,
other _view _modes : options . other _view _modes
} ,
2018-11-23 12:29:20 +00:00
success : function success ( response , status ) {
var _this = this ;
Object . keys ( response || { } ) . forEach ( function ( i ) {
if ( response [ i ] . command && _this . commands [ response [ i ] . command ] ) {
_this . commands [ response [ i ] . command ] ( _this , response [ i ] , status ) ;
2015-08-18 00:00:26 +00:00
}
2018-11-23 12:29:20 +00:00
} ) ;
2015-08-18 00:00:26 +00:00
} ,
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
base : $submit . attr ( 'id' ) ,
element : $submit [ 0 ]
} ;
return Drupal . ajax ( settings ) ;
} ,
2018-11-23 12:29:20 +00:00
unajaxifySaving : function unajaxifySaving ( ajax ) {
2015-08-18 00:00:26 +00:00
$ ( ajax . element ) . off ( 'click.quickedit' ) ;
}
} ;
2018-11-23 12:29:20 +00:00
} ) ( jQuery , Drupal ) ;