-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lagt till import av filer Lagt till ajax anrop för att importera filer Hämtning av post_id för redan importerade filer
- Loading branch information
Showing
4 changed files
with
856 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pp-bilder-container { | ||
display: none; | ||
} | ||
|
||
#pp-bilder { | ||
padding: 20px; | ||
} | ||
|
||
#pp-bilder img { | ||
border: solid 1px #ccc; | ||
margin: 10px; | ||
cursor: pointer; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(function($){ | ||
|
||
var PPBilder = { | ||
|
||
init: function() { | ||
$(document).on('click', '#pp-bilder img', this.clickHandler); | ||
}, | ||
|
||
clickHandler: function() { | ||
var $this = $(this), | ||
filename = $this.data('filename'), | ||
post_id = $this.data('post-id'); | ||
|
||
if ( !post_id && !filename ) { | ||
PPBilder.showError(); | ||
return; | ||
} | ||
|
||
if ( filename ) { | ||
var jqxhr = PPBilder.importImage( filename ); | ||
|
||
jqxhr.done(function(data) { | ||
/[0-9]+/.test(data) ? | ||
PPBilder.selectImage(data) : | ||
PPBilder.showError(); | ||
}); | ||
} else { | ||
PPBilder.selectImage(post_id); | ||
} | ||
}, | ||
|
||
importImage: function(filename) { | ||
|
||
//noinspection JSUnresolvedVariable | ||
return $.post(ajaxurl, { | ||
action:'pp_bilder_import_image', | ||
filename:filename | ||
}); | ||
}, | ||
|
||
selectImage: function(post_id) { | ||
console.log('todo: implement selectImage'); | ||
}, | ||
|
||
showError: function() { | ||
console.log('todo: implement showError'); | ||
} | ||
}; | ||
|
||
PPBilder.init(); | ||
|
||
}(jQuery)); |
Oops, something went wrong.