Этот коммит содержится в:
Igor V Belousov 2015-06-09 16:11:49 +03:00
родитель 0153b3b1d0
Коммит 16636f3a27
8 изменённых файлов: 94 добавлений и 4 удалений

51
Gruntfile.js Обычный файл
Просмотреть файл

@ -0,0 +1,51 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
batch: {
src: 'js/batch.js',
dest: 'js/batch.min.js'
}
},
stylus: {
compile: {
files: {
'css/batch.css':'css/batch.styl'
}
}
},
csso: {
dist: {
files: {
'css/batch.css':'css/batch.css'
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-internal');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-csso');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.registerTask('js',['uglify']);
grunt.registerTask('css',['stylus','csso']);
// Default task(s).
grunt.registerTask('default', ['css','js']);
};

Просмотреть файл

@ -77,11 +77,12 @@ function batch_operations_add_page() {
* View batch operations page * View batch operations page
*/ */
function batch_operations_page_view() { function batch_operations_page_view() {
global $batch_operations_version;
global $wpdb; global $wpdb;
//WP>=3.3 //WP>=3.3
wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'batch_operations_script', plugin_dir_url('') . 'batch_operations/js/batch.min.js' ); wp_enqueue_script( 'batch_operations_script', plugin_dir_url('') . 'batch_operations/js/batch.min.js', array(), $batch_operations_version );
wp_enqueue_style( 'batch_operations_script', plugin_dir_url('') . 'batch_operations/css/batch.css' ); wp_enqueue_style( 'batch_operations_script', plugin_dir_url('') . 'batch_operations/css/batch.css', array(), $batch_operations_version );
$id = ( intval( $_REQUEST["id"] ) < 0 )? 0 : intval( $_REQUEST["id"] ); $id = ( intval( $_REQUEST["id"] ) < 0 )? 0 : intval( $_REQUEST["id"] );
@ -105,6 +106,7 @@ function batch_operations_page_view() {
<div class="batch-progress"> <div class="batch-progress">
<span style="width:0%;"></span> <span style="width:0%;"></span>
</div> </div>
<div class="batch-progress-message"></div><div class="batch-percent"></div>
<div class="batch-message"><?php echo $init_message; ?></div> <div class="batch-message"><?php echo $init_message; ?></div>
</div> </div>

Просмотреть файл

@ -30,6 +30,14 @@ function batch_operations_test_page_view() {
batch_operations_start($batch); batch_operations_start($batch);
break; break;
case 4:
$batch['operations'][]=array('test_batch_operation',array());
$batch['operations'][]=array('test_batch_operation',array());
$batch['operations'][]=array('test_batch_operation',array());
$batch['operations'][]=array('test_batch_operation',array());
$batch['operations'][]=array('test_batch_operation',array());
batch_operations_start($batch);
break;
default: default:
break; break;
} }
@ -42,6 +50,7 @@ function batch_operations_test_page_view() {
<li><a href="tools.php?page=batch-operations&id=0">$current_array is empty</a> <li><a href="tools.php?page=batch-operations&id=0">$current_array is empty</a>
<li><a href="tools.php?page=batch-operations-test&test=2">Default <strong>title</strong> & <strong>init_message</strong></a> <li><a href="tools.php?page=batch-operations-test&test=2">Default <strong>title</strong> & <strong>init_message</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=3">Set <strong>custom title</strong> & <strong>custom init_message</strong></a> <li><a href="tools.php?page=batch-operations-test&test=3">Set <strong>custom title</strong> & <strong>custom init_message</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=4">5 operations</a>
</ol> </ol>
</div> </div>
<?php <?php

Просмотреть файл

@ -1 +1 @@
.batch-progress{height:30px;position:relative;background:#fff;-webkit-border-radius:8px;-moz-border-radius:8px;-o-border-radius:8px;-ms-border-radius:8px;-khtml-border-radius:8px;border-radius:8px;border:1px solid #ccc;margin:10px 0;padding:2px}.batch-progress>span{display:block;height:100%;background-color:#1834ff;background-image:-moz-linear-gradient(#4d80ff,#002ffb);background-image:-webkit-linear-gradient(#4d80ff,#002ffb);background-image:-o-linear-gradient(#4d80ff,#002ffb);background-image:-ms-linear-gradient(#4d80ff,#002ffb);background-image:linear-gradient(#4d80ff,#002ffb);-webkit-border-radius:6px;-moz-border-radius:6px;-o-border-radius:6px;-ms-border-radius:6px;-khtml-border-radius:6px;border-radius:6px;position:relative;overflow:hidden} .batch-progress{height:30px;position:relative;background:#fff;-webkit-border-radius:8px;-moz-border-radius:8px;-o-border-radius:8px;-ms-border-radius:8px;-khtml-border-radius:8px;border-radius:8px;border:1px solid #ccc;margin:10px 0;padding:2px}.batch-progress>span{display:block;height:100%;background-color:#1834ff;background-image:-moz-linear-gradient(#4d80ff,#002ffb);background-image:-webkit-linear-gradient(#4d80ff,#002ffb);background-image:-o-linear-gradient(#4d80ff,#002ffb);background-image:-ms-linear-gradient(#4d80ff,#002ffb);background-image:linear-gradient(#4d80ff,#002ffb);-webkit-border-radius:6px;-moz-border-radius:6px;-o-border-radius:6px;-ms-border-radius:6px;-khtml-border-radius:6px;border-radius:6px;position:relative;overflow:hidden}.batch-percent{float:right}.batch-percent,.batch-progress-message{display:inline-block}.batch-progress-message,.batch-percent,.batch-message{font-size:120%;font-weight:700}

Просмотреть файл

@ -17,3 +17,16 @@
-pos relative -pos relative
overflow hidden overflow hidden
.batch-percent
-d inline-block
-fl right
.batch-progress-message
-d inline-block
.batch-progress-message
.batch-percent
.batch-message
-fs 120%
-fw 700

Просмотреть файл

@ -1,5 +1,6 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
var batch_progress = function (percent){ var batch_progress = function (percent){
$(".batch-percent").html(percent + "%");
return $(".batch-progress > span").animate({ width: percent + "%" }, 600); return $(".batch-progress > span").animate({ width: percent + "%" }, 600);
}; };

2
js/batch.min.js поставляемый
Просмотреть файл

@ -1 +1 @@
jQuery(document).ready(function(a){function b(){a.post(ajaxurl+"?action=batch_operations&id="+batch_id,function(d){"finish"==d["do"]?(c(d.percent),a(".batch-message").html(d.message).delay(1500).queue(function(){a(location).attr("href",successful_page),a(this).dequeue()})):(a(".batch-message").html(d.message),c(d.percent),b())})}var c=function(b){return a(".batch-progress > span").animate({width:b+"%"},600)};b()}); jQuery(document).ready(function(a){function b(){a.post(ajaxurl+"?action=batch_operations&id="+batch_id,function(d){"finish"==d["do"]?(c(d.percent),a(".batch-message").html(d.message).delay(1500).queue(function(){a(location).attr("href",successful_page),a(this).dequeue()})):(a(".batch-message").html(d.message),c(d.percent),b())})}var c=function(b){return a(".batch-percent").html(b+"%"),a(".batch-progress > span").animate({width:b+"%"},600)};b()});

14
package.json Обычный файл
Просмотреть файл

@ -0,0 +1,14 @@
{
"name": "Batch_operations",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-internal": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-csso": "~0.5.0",
"grunt-contrib-stylus": "~0.10.0"
}
}